<template>
  <div class="container" v-if="orderDetail">
    <div class="top">
      <van-nav-bar
        fixed
        left-text="返回"
        title="订单详情"
        left-arrow
        @click-left="onClickLeft"
      >
      </van-nav-bar>
    </div>
    <div class="middle">
      <div class="name">
        <van-icon name="contact" />宾客姓名：{{ orderDetail.name }}
      </div>
      <div class="phone">
        <van-icon name="phone-o" />联系电话：{{ orderDetail.phone }}
      </div>
      <div class="roomInfo">
        <van-card
          :num="orderDetail.room_num"
          :price="orderDetail.prcie"
          :desc="orderDetail.room_type"
          :title="orderDetail.hotel_title"
          :thumb="orderDetail.room_img"
        />
      </div>
      <div class="total">
        <span style="font-weight: bold; color: black">订单总额：</span
        ><span>￥{{ orderDetail.room_prcie.toFixed(2) }}元</span>
      </div>
      <div class="info">
        <div class="people">
          <span style="font-weight: bold; color: black">入住人数：</span>
          <span>共{{ orderDetail.people_num }}人</span>
        </div>
        <div class="orderNo">
          <span style="font-weight: bold; color: black">订单编号：</span>
          <span>{{ `XED${orderDetail.id}00364521` }}</span>
        </div>
        <div class="enter">
          <span style="font-weight: bold; color: black"> 入住时间：</span>
          <span>{{ orderDetail.check_in.slice(0, 10) }}</span>
        </div>
        <div class="leave">
          <span style="font-weight: bold; color: black"> 离店时间：</span>
          <span>{{ orderDetail.leave.slice(0, 10) }} </span>
        </div>
      </div>
    </div>
    <div class="bottom">
      <van-button
        type="primary"
        size="large"
        @click.stop="again(orderDetail.hid)"
        >再次预定</van-button
      >
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      id: this.$route.query.id,
    };
  },
  computed: {
    ...mapState({
      orderDetail: (state) => state.order.orderDetail,
    }),
  },
  mounted() {
    this.$store.dispatch("getOrderDetail", this.id);
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    again(hid) {
      this.$router.push(`/hotel?id=${hid}`);
    },
  },
};
</script>
<style lang='scss' scoped>
.top {
  height: 13vw;
  .van-nav-bar {
    background-color: transparent;
    background-color: #f5b400;
    color: #fff;

    ::v-deep .van-nav-bar__text,
    ::v-deep .van-nav-bar__title,
    ::v-deep .van-icon {
      color: #fff;
    }
  }
  ::v-deep .van-hairline--bottom::after {
    border-bottom-width: 0px;
  }
}
.container {
  height: 100vh;
  background-color: #eee;

  .name {
    margin-top: 1vw;
    padding-top: 2vw;
  }
  .name,
  .phone {
    background-color: #fff;
    padding-left: 10vw;
    padding-bottom: 2vw;
    color: #555;
    .van-icon {
      padding-right: 2vw;
    }
  }

  .van-card {
    margin: 2vw 0;
    font-size: 15px;
    background-color: #fff;
  }
  ::v-deep .van-card__desc {
    padding-top: 2vw;
  }
  ::v-deep .van-card__title {
    padding-top: 2vw;
  }

  .info {
    background-color: #fff;
  }

  .total {
    margin: 2vw 0;
    background-color: #fff;
  }

  .total,
  .people,
  .orderNo,
  .enter,
  .leave {
    padding: 3vw 10vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
    font-size: 14px;
  }
}

.bottom {
  position: absolute;
  bottom: 0;
  width: 100vw;
  .van-button {
    border: #f5b400;
    background-color: #f5b400;
  }
}
</style>